package com.zzw.hj22;

import java.util.Scanner;

/**
 * @Project: hw_java
 * @Description: 汽水瓶
 * @Author: zzw
 */

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNextInt()) {
            int n = in.nextInt();
            if (n == 0) {
                break;
            }
            int count = 0;
            while (n > 0) {
                count += n / 3;
                int rem = n % 3;
                // 如果剩两个瓶子，刚好可以借一个再还
                if ((n / 3 + rem) == 2) {
                    count++;
                    break;
                } else if ((n / 3 + rem) / 3 > 0) {
                    n = n / 3 + rem;
                } else {
                    break;
                }
            }
            System.out.println(count);
        }
    }
}